// ============================================================================
//
// Copyright (C) 2006-2007 Dengues
//
// Google Group: http://groups.google.com/group/dengues
// QQ Group: 24885404
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// ============================================================================
package org.dengues.warehouse.models;

import org.dengues.core.warehouse.ENavNodeType;
import org.dengues.core.warehouse.ENodeCategoryName;
import org.dengues.core.warehouse.IWarehouseObject;
import org.dengues.model.database.DatabaseDiagram;
import org.dengues.model.warehouse.ProcessType;

/**
 * Qiang.Zhang.Adolf@gmail.com class global comment. Detailled comment <br/>
 * 
 * $Id: Dengues.epf 2008-1-7 qiang.zhang $
 * 
 */
public class WarehouseObject implements IWarehouseObject {

    private ENodeCategoryName categoryName;

    private ENavNodeType nodeType;

    private Object data;

    private String label;

    /**
     * Qiang.Zhang.Adolf@gmail.com WarehouseObject constructor comment.
     * 
     * @param object
     */
    public WarehouseObject(Object object) {
        this.data = object;
    }

    /**
     * Getter for categoryName.
     * 
     * @return the categoryName
     */
    public ENodeCategoryName getCategoryName() {
        return this.categoryName;
    }

    /**
     * Sets the categoryName.
     * 
     * @param categoryName the categoryName to set
     */
    public void setCategoryName(ENodeCategoryName categoryName) {
        this.categoryName = categoryName;
    }

    /**
     * Getter for nodeType.
     * 
     * @return the nodeType
     */
    public ENavNodeType getNodeType() {
        return this.nodeType;
    }

    /**
     * Sets the nodeType.
     * 
     * @param nodeType the nodeType to set
     */
    public void setNodeType(ENavNodeType nodeType) {
        this.nodeType = nodeType;
    }

    /**
     * Getter for data.
     * 
     * @return the data
     */
    public Object getData() {
        return this.data;
    }

    /**
     * Sets the data.
     * 
     * @param data the data to set
     */
    public void setData(Object data) {
        this.data = data;
    }

    public String getLabel() {
        if (label == null) {
            if (data instanceof DatabaseDiagram) {
                label = ((DatabaseDiagram) data).getName();
            } else if (data instanceof ProcessType) {
                label = ((ProcessType) data).getName();
            }
        }
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

}
